package com.example.blogdemo.configuration;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import lombok.extern.slf4j.Slf4j;

/**
 * @Author Anita
 * @Date 2018/1/3 10:58
 */
@Configuration
@Slf4j
public class WebAppConfig extends WebMvcConfigurerAdapter {
    //获取配置文件中图片的路径
    private String mImagesPath = "file:/D:/img/";
    //访问图片方法
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
       log.info("imagesPath="+mImagesPath);
        registry.addResourceHandler("/images/**").addResourceLocations(mImagesPath);
        super.addResourceHandlers(registry);
    }
}
